# coding: utf-8
from flask_sqlalchemy import SQLAlchemy
from app import constants
from werkzeug.security import generate_password_hash,check_password_hash


db = SQLAlchemy()


class BaseArea(db.Model):
    __tablename__ = 'base_area'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    parent_id = db.Column(db.BigInteger, info='上级区域')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    region_code = db.Column(db.String(1000, 'utf8mb4_0900_ai_ci'), info='所属行政区划编码')
    region_name = db.Column(db.String(1000, 'utf8mb4_0900_ai_ci'), info='所属行政区划名称')
    area_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='名称')
    postal_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='邮政编码')
    longitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='经度')
    latitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纬度')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态')

    def to_dict(self):
        d = {
            "id":self.id  ,
            "area_name": self.area_name
        }
        return d

class BaseBusinessOutlet(db.Model):
    __tablename__ = 'base_business_outlet'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    open_date_range = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='营业时间')
    network_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='营业网点名称')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='地址')
    phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='电话')
    longitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='经度')
    latitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纬度')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, nullable=False, info='是否删除')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态')



class BaseParameter(db.Model):
    __tablename__ = 'base_parameter'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    alarm_water_consumption = db.Column(db.BigInteger, info='报警用水量')
    magnetic_interference_action = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='磁干扰动作')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class BladeDept(db.Model):
    __tablename__ = 'blade_dept'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    parent_id = db.Column(db.BigInteger, index=True, server_default=db.FetchedValue(), info='父主键')
    ancestors = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='祖级列表')
    dept_category = db.Column(db.Integer, info='部门类型')
    dept_name = db.Column(db.String(45, 'utf8mb4_0900_ai_ci'), info='部门名')
    full_name = db.Column(db.String(45, 'utf8mb4_0900_ai_ci'), info='部门全称')
    sort = db.Column(db.Integer, info='排序')
    remark = db.Column(db.String(255, 'utf8mb4_0900_ai_ci'), info='备注')
    is_deleted = db.Column(db.Integer, server_default=db.FetchedValue(), info='是否已删除')
    code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='企业代码')
    business_license_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='统一社会信用代码')
    region_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='行政区划')
    region_ancestors = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='行政区划祖级')
    address = db.Column(db.String(300, 'utf8mb4_0900_ai_ci'), info='详细地址')
    longitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='经度')
    latitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纬度')
    legal_person_name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='法人姓名')
    legal_id_card_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='法人身份证号')
    legal_id_card_front = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='法人身份证正面')
    legal_id_card_back = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='法人身份证反面')
    legal_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='法人手机号码')
    registered_capital = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='注册资金(万元）')
    contact_name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='企业联系人姓名')
    contact_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='联系人手机')
    contact_mail = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), info='联系人邮箱')
    business_scope = db.Column(db.Text(collation='utf8mb4_0900_ai_ci'), info='经营范围')
    valid_date = db.Column(db.Date, info='有效期')
    organ_name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='登记机关')
    business_license_image = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='营业执照图片')



class CInvoiceTitle(db.Model):
    __tablename__ = 'c_invoice_title'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    user_id = db.Column(db.BigInteger, info='用户id')
    billing_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='开票类型:个人、企业')
    name = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), info='名称')
    tax_number = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='税号')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='地址')
    phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='电话')
    bank = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='开户行')
    account_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='开户账号')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class CUser(db.Model):
    __tablename__ = 'c_user'

    id = db.Column(db.BigInteger, primary_key=True, info='用户Id')
    mobile = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='手机号')
    password = db.Column(db.String(64, 'utf8mb4_0900_ai_ci'), info='密码(密文)')
    nick_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='昵称')
    photo = db.Column(db.String(200, 'utf8_general_ci'), info='头像')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态: 可用、不可用')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')

    @property
    def password(self):
        """
        读取属性的函数行为
        :return:
        """
        # print(user.password)  # 读取属性时被调用
        # 函数的返回值会作为属性值
        # return "xxxx"
        raise AttributeError("这个属性只能设置，不能读取")

    # 使用这个装饰器，对应设置属性操作
    @password.setter
    def password(self, value):
        """
        设置属性  user.password = "xxxx"
        :param value: 设置属性时的数据， value就是“xxx”, 原始的明文密码
        :return:
        """
        self.password = generate_password_hash(value)

    def check_password(self,passwd):
        """
        校验密码的正确性
        :param passwd: 用户登录时填写的原始密码
        :return: 如果正确，返回True, 否则返回False
        """
        return check_password_hash(self.password,passwd)

    def to_dict(self):
        """将数据转换为字典"""
        user_dict = {
            "user_id": self.id,
            "name": self.nick_name,
            "mobile": self.mobile,
            "avatar": constants.QINIU_URL_DOMAIN + self.photo if self.photo else "" ,
            "craete_time": self.create_time.strftime("%Y-%m-%d %H:%M:%S")
        }
        return user_dict





class CUserBinding(db.Model):
    __tablename__ = 'c_user_binding'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    user_id = db.Column(db.BigInteger, nullable=False, info='用户ID')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')



class CUserMessage(db.Model):
    __tablename__ = 'c_user_message'

    id = db.Column(db.BigInteger, primary_key=True, info='消息记录主键')
    receive_user_id = db.Column(db.BigInteger, info='接收人id')
    message_title = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='消息标题')
    message_content = db.Column(db.String(3000, 'utf8mb4_0900_ai_ci'), info='消息内容')
    is_read = db.Column(db.Integer, info='是否已读')
    is_send = db.Column(db.Integer, info='是否已发送')
    source = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='来源')
    read_date_time = db.Column(db.DateTime, info='读取时间')
    send_date_time = db.Column(db.DateTime, info='消息发送时间')
    scheduled_send_time = db.Column(db.DateTime, info='计划发送时间')



class CWechatUser(db.Model):
    __tablename__ = 'c_wechat_user'

    id = db.Column(db.BigInteger, primary_key=True, info='用户Id')
    user_id = db.Column(db.BigInteger, info='用户Id')
    app_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='app_id')
    open_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='微信openid')
    nick_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='昵称')
    gender = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='性别')
    province = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='省份')
    city = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='城市')
    country = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='国家')
    avatar_url = db.Column(db.String(400, 'utf8mb4_0900_ai_ci'), info='头像')
    union_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='用户统一标识')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class CmsArticle(db.Model):
    __tablename__ = 'cms_article'

    id = db.Column(db.BigInteger, primary_key=True, info='ID')
    title = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='标题')
    source = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='来源')
    release_date = db.Column(db.DateTime, info='发布日期')
    category_id = db.Column(db.BigInteger, nullable=False, info='类别')
    author = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='作者')
    content = db.Column(db.Text(collation='utf8mb4_0900_ai_ci'), nullable=False, info='内容')
    abstract_note = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='摘要')
    external_links = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='外部链接')
    cover_photo = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='封面图')
    home_first = db.Column(db.Integer, info='首页优先')
    recommend = db.Column(db.Integer, info='推荐')
    release_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='发布状态')
    area_ids = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='区域ID')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建科室')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, nullable=False, info='是否删除')



class CmsCategory(db.Model):
    __tablename__ = 'cms_category'

    id = db.Column(db.BigInteger, primary_key=True, info='id')
    parent_id = db.Column(db.BigInteger, info='父级ID')
    name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='类别名称')
    sort = db.Column(db.Integer, info='排序')
    level = db.Column(db.Integer, info='级别')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建科室')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class PayTradeOrder(db.Model):
    __tablename__ = 'pay_trade_order'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    merchant_order_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='商户订单号')
    dept_id = db.Column(db.BigInteger, nullable=False, info='商户Id')
    user_id = db.Column(db.BigInteger, nullable=False, info='用户id')
    subject = db.Column(db.String(300, 'utf8mb4_0900_ai_ci'), info='商品名称')
    pay_way = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='支付方式：1现金，2余额，3网银，4支付宝，5微信')
    pay_channel = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='支付渠道（微信APP/支付宝app）')
    total_amount = db.Column(db.Numeric(12, 2), nullable=False, info='订单总金额')
    pay_amount = db.Column(db.Numeric(12, 2), nullable=False, info='支付金额')
    discount_amount = db.Column(db.Numeric(12, 2), nullable=False, info='优惠金额')
    order_time = db.Column(db.DateTime, nullable=False, info='下单时间')
    order_ip = db.Column(db.String(30, 'utf8mb4_0900_ai_ci'), info='下单ip')
    order_success_time = db.Column(db.DateTime, info='支付成功时间')
    trade_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='交易类型：充值、扣费、退款')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='订单状态:已创建、已取消、交易成功、待支付')
    is_refund = db.Column(db.Integer, info='是否退款')
    refund_times = db.Column(db.Integer, info='退款次数')
    success_refund_amount = db.Column(db.Numeric(12, 2), info='成功退款总金额')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='备注')
    dept_body = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='商户扩展')
    user_body = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='用户扩展字段')
    biz_body = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='业务扩展字段')



class PayTradeRecord(db.Model):
    __tablename__ = 'pay_trade_record'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    trade_order_id = db.Column(db.BigInteger, info='交易订单ID')
    merchant_order_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='商户订单号')
    dept_id = db.Column(db.BigInteger, nullable=False, info='商户id')
    user_id = db.Column(db.BigInteger, nullable=False, info='用户id')
    subject = db.Column(db.String(300, 'utf8mb4_0900_ai_ci'), info='商品名称')
    trade_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='支付流水号')
    out_trade_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='三方流水号')
    amount = db.Column(db.Numeric(12, 2), nullable=False, info='交易金额')
    order_ip = db.Column(db.String(30, 'utf8mb4_0900_ai_ci'), info='下单ip')
    trade_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='交易业务类型  ：充值等')
    pay_channel = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='支付渠道：微信、支付宝、现金、银行')
    trade_time = db.Column(db.DateTime, nullable=False, info='支付创建时间')
    trade_success_time = db.Column(db.DateTime, info='支付成功时间')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='状态：处理中、成功、完成')
    is_refund = db.Column(db.Integer, info='是否退款')
    refund_times = db.Column(db.Integer, info='退款次数')
    success_refund_amount = db.Column(db.Numeric(12, 2), info='成功退款总金额')
    is_checked = db.Column(db.Integer)
    dept_body = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='商户扩展字段')
    user_body = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='用户扩展字段')
    biz_body = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='业务扩展字段')



class SettleClearing(db.Model):
    __tablename__ = 'settle_clearing'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    clearing_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='清分单号')
    dept_id = db.Column(db.BigInteger, nullable=False, info='清分对象')
    total_amount = db.Column(db.Numeric(12, 2), info='总金额')
    trade_count = db.Column(db.Integer, info='交易总笔数')
    clearing_time = db.Column(db.DateTime, info='清分时间')
    start_time = db.Column(db.DateTime, info='起始时间')
    end_time = db.Column(db.DateTime, info='结束时间')
    account_period = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='清分账期')
    trade_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='订单类型')
    trade_order_ids = db.Column(db.String(collation='utf8mb4_0900_ai_ci'), info='交易订单号')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    settlement_id = db.Column(db.BigInteger, info='清算单ID')



class SettlePlatServiceFee(db.Model):
    __tablename__ = 'settle_plat_service_fee'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    plat_service_fee_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='费用单号')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构')
    price = db.Column(db.Numeric(12, 2), info='单表费用')
    meter_num = db.Column(db.Integer, info='水表数量')
    total_amount = db.Column(db.Numeric(12, 2), info='总金额')
    fee_time = db.Column(db.DateTime, nullable=False, info='费用时间')
    start_time = db.Column(db.DateTime, info='开始时间')
    end_time = db.Column(db.DateTime, info='结束时间')
    account_period = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='账期')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='单据状态')



class SettleSettlement(db.Model):
    __tablename__ = 'settle_settlement'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    settlement_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='清算单号')
    dept_id = db.Column(db.BigInteger, nullable=False, info='清算对象')
    total_amount = db.Column(db.Numeric(12, 2), info='总金额')
    trade_count = db.Column(db.Integer, info='交易总笔数')
    settlement_time = db.Column(db.DateTime, nullable=False, info='清算时间')
    start_time = db.Column(db.DateTime, info='起始时间')
    end_time = db.Column(db.DateTime, info='结束时间')
    account_period = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='清算账期')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='清算状态')



class SettleSettlementDetail(db.Model):
    __tablename__ = 'settle_settlement_detail'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    settlement_id = db.Column(db.BigInteger, nullable=False, info='清算ID')
    clearing_id = db.Column(db.BigInteger, nullable=False, info='清分ID')
    clearing_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='清分单号')
    account_period = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='清分账期')
    trade_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='交易类型')
    total_amount = db.Column(db.Numeric(12, 2), nullable=False, info='交易金额')
    trade_count = db.Column(db.Integer, info='交易总笔数')
    dept_id = db.Column(db.BigInteger, nullable=False, info='交易对象')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class SettleSettlementLog(db.Model):
    __tablename__ = 'settle_settlement_log'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    dept_id = db.Column(db.BigInteger, nullable=False, info='清算对象')
    settlement_time = db.Column(db.DateTime, nullable=False, info='清算时间')
    account_period = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='清算账期')
    log = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), info='日志')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='状态')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WmDevice(db.Model):
    __tablename__ = 'wm_device'

    id = db.Column(db.BigInteger, primary_key=True, info='设备Id')
    parent_id = db.Column(db.BigInteger)
    category_id = db.Column(db.BigInteger, info='设备分类')
    device_model_id = db.Column(db.BigInteger, info='设备型号')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='表号')
    manufacturer_name = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), info='水表厂商')
    max_number = db.Column(db.Integer, nullable=False, info='最大读数')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='当前状态')
    online_time = db.Column(db.DateTime, info='上线时间')
    imei = db.Column(db.String(15, 'utf8mb4_0900_ai_ci'), info='IMEI')
    plat_device_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='平台设备ID')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WmDeviceCategory(db.Model):
    __tablename__ = 'wm_device_category'

    id = db.Column(db.BigInteger, primary_key=True, info='分类Id')
    code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='编码')
    name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='名称')
    sort = db.Column(db.Integer, info='排序')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='备注')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WmDeviceModel(db.Model):
    __tablename__ = 'wm_device_model'

    id = db.Column(db.BigInteger, primary_key=True, info='型号Id')
    device_category_id = db.Column(db.BigInteger, info='分类ID')
    name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='名称')
    max_number = db.Column(db.Integer, info='最大读数')
    day_max_number = db.Column(db.Integer, info='日最大用水量')
    is_write_back = db.Column(db.Integer, nullable=False, info='是否回写')
    sort = db.Column(db.Integer, info='排序')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='备注')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WmWaterMeterSetting(db.Model):
    __tablename__ = 'wm_water_meter_setting'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    device_category_id = db.Column(db.BigInteger, info='设备类型')
    device_model_id = db.Column(db.BigInteger, info='设备型号')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    max_number = db.Column(db.Integer, info='最大读数')
    max_read_period = db.Column(db.Integer, info='最大上报间隔')
    prepaid_number = db.Column(db.Integer, info='预存量')
    over_number = db.Column(db.Integer, info='透支量')
    is_deduction = db.Column(db.Integer, info='是否扣减')
    alarm_water_consumption = db.Column(db.Numeric(12, 0), info='报警量')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    day_max_number = db.Column(db.Integer, info='日最大用水量')



class WuAccountDeduction(db.Model):
    __tablename__ = 'wu_account_deduction'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    water_meter_id = db.Column(db.BigInteger, info='水表ID')
    meter_record_id = db.Column(db.BigInteger, info='抄表记录ID')
    trade_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='扣费单号')
    last_water_meter_digital = db.Column(db.Numeric(12, 3), info='上次水表读数')
    water_meter_digital = db.Column(db.Numeric(12, 3), info='本期水表读数')
    water_consumption = db.Column(db.Numeric(12, 3), info='本期用水量')
    water_price = db.Column(db.Numeric(8, 2), info='本期水费阶梯单价')
    deduction_amount = db.Column(db.Numeric(8, 2), info='应扣金额')
    discount_amount = db.Column(db.Numeric(8, 2), info='优惠金额')
    real_deduction_amount = db.Column(db.Numeric(8, 2), info='实扣金额')
    deduction_date_time = db.Column(db.DateTime, info='扣费时间')
    balance_before = db.Column(db.Numeric(8, 2), info='扣费前余额')
    balance_after = db.Column(db.Numeric(8, 2), info='扣费后余额')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    area_id = db.Column(db.BigInteger, info='片区id')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuAccountDeductionDetail(db.Model):
    __tablename__ = 'wu_account_deduction_detail'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    account_deduction_id = db.Column(db.BigInteger, info='扣费单id')
    price_name = db.Column(db.String(20, 'utf8mb4_general_ci'), info='名称')
    fee_type = db.Column(db.String(20, 'utf8mb4_general_ci'), info='费用类型')
    step_number = db.Column(db.Integer, info='阶梯数')
    water_consumption = db.Column(db.Numeric(12, 3), info='本期用水量')
    deduction_amount = db.Column(db.Numeric(12, 2), info='应扣金额')



class WuAccountInvoice(db.Model):
    __tablename__ = 'wu_account_invoice'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    bill_ids = db.Column(db.String(2000, 'utf8mb4_0900_ai_ci'), nullable=False, info='账单ids，逗号隔开')
    user_id = db.Column(db.BigInteger, nullable=False, info='注册用户id')
    water_user_id = db.Column(db.BigInteger, nullable=False, info='用水户id')
    invoice_no = db.Column(db.BigInteger, info='发票号')
    invoice_code = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='发票代码')
    name = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), info='发票抬头')
    invoice_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='发票类型：普票、专票')
    invoice_category = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='发票类别：电子发票、纸质发票')
    invoice_amount = db.Column(db.Numeric(12, 2), info='发票金额')
    invoice_tax = db.Column(db.Numeric(12, 2), info='发票税额')
    invoice_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='开票状态：待开票、开票中、已开票')
    invoice_file = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='发票附件')
    tax_number = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纳税人识别号[增值税]')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='公司地址[增值税]')
    phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='联系电话[增值税]')
    bank = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='开户银行[增值税]')
    account_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='银行帐号[增值税]')
    billing_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='开票人')
    billing_time = db.Column(db.DateTime, info='开票时间')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构id')
    area_id = db.Column(db.BigInteger, nullable=False, info='区域id')
    email = db.Column(db.String(100, 'utf8mb4_0900_ai_ci'), info='邮箱地址')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuAccountOverdue(db.Model):
    __tablename__ = 'wu_account_overdue'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    trade_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='滞纳金单号')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    water_meter_id = db.Column(db.BigInteger, info='水表id')
    current_arrearage = db.Column(db.Numeric(12, 2), info='欠费总金额')
    late_fee_calculation_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='滞纳金计算方式')
    late_fee_amount = db.Column(db.Numeric(8, 2), info='滞纳金日利率（日金额）')
    overdue_amount = db.Column(db.Numeric(8, 2), info='本期滞纳金')
    overdue_days = db.Column(db.Integer, info='计费天数')
    billing_date_time = db.Column(db.DateTime, info='计费时间')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    area_id = db.Column(db.BigInteger, info='片区id')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuAccountRecharge(db.Model):
    __tablename__ = 'wu_account_recharge'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    user_id = db.Column(db.BigInteger, info='注册用户id')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    water_meter_id = db.Column(db.BigInteger, info='水表ID')
    trade_no = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='充值单号')
    pay_way = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='支付方式')
    pay_channel = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='支付渠道')
    recharge_date_time = db.Column(db.DateTime, info='充值时间')
    recharge_amount = db.Column(db.Numeric(8, 2), info='充值金额')
    balance_before = db.Column(db.Numeric(8, 2), info='充值前余额')
    balance_after = db.Column(db.Numeric(8, 2), info='充值后余额')
    overdue_before = db.Column(db.Numeric(8, 2), info='充值前滞纳金')
    overdue_after = db.Column(db.Numeric(8, 2), info='充值后滞纳金')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='支付状态:支付成功、支付失败、支付超时（需根据实际情况考虑订单的时效性）')
    print_num = db.Column(db.Integer, info='打印次数')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    area_id = db.Column(db.BigInteger, info='片区id')
    operate_user = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='操作人')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuAccountRefund(db.Model):
    __tablename__ = 'wu_account_refund'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    water_meter_id = db.Column(db.BigInteger, info='水表ID')
    trade_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='交易单号')
    pay_way = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='支付方式')
    pay_channel = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='退款渠道')
    refund_amount = db.Column(db.Numeric(8, 2), info='退款金额')
    balance_before = db.Column(db.Numeric(8, 2), info='退款前余额')
    balance_after = db.Column(db.Numeric(8, 2), info='退款后余额')
    refund_reason = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='退款原因')
    operate_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='操作人')
    operate_time = db.Column(db.DateTime, info='操作时间')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    area_id = db.Column(db.BigInteger, info='片区id')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuChangeReason(db.Model):
    __tablename__ = 'wu_change_reason'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    content = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='内容')
    sort = db.Column(db.Integer, info='排序')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuDeductionLog(db.Model):
    __tablename__ = 'wu_deduction_log'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    period = db.Column(db.Date, info='计算周期')
    success_num = db.Column(db.Integer, info='扣费成功数量')
    fail_num = db.Column(db.Integer, info='扣费失败数量')



class WuDeviceAlarm(db.Model):
    __tablename__ = 'wu_device_alarm'

    id = db.Column(db.BigInteger, primary_key=True, info='报警Id')
    water_meter_id = db.Column(db.BigInteger, info='水表id')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    read_number = db.Column(db.Numeric(12, 3), nullable=False, info='读数')
    voltage = db.Column(db.Numeric(12, 2), info='电压')
    valve_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='阀门状态')
    voltage_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='电压状态')
    alarm_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='报警状态:\\n            水表异常(读取异常)、水表异常(读取校验失败)、电压偏低、电压过低、电池掉电、磁攻击')
    signal_quality = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='信号质量')
    alarm_time = db.Column(db.DateTime, info='上报时间')
    deal_explain = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='处理说明')
    deal_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='处理状态:待处理、关闭')
    deal_time = db.Column(db.DateTime, info='处理时间')
    deal_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='处理人')
    dept_id = db.Column(db.BigInteger, info='机构ID')



class WuMeterRecord(db.Model):
    __tablename__ = 'wu_meter_record'

    id = db.Column(db.BigInteger, primary_key=True, info='记录Id')
    plat_device_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='平台设备ID')
    water_meter_id = db.Column(db.BigInteger, nullable=False, info='水表ID')
    device_id = db.Column(db.BigInteger, nullable=False, info='设备id')
    imei = db.Column(db.String(15, 'utf8mb4_0900_ai_ci'), nullable=False, info='IMEI')
    device_model_id = db.Column(db.BigInteger, nullable=False, info='设备型号ID')
    read_number = db.Column(db.Numeric(12, 3), nullable=False, info='读数')
    period_number = db.Column(db.Numeric(12, 3), nullable=False, info='上期用水读数')
    last_read_number = db.Column(db.Numeric(12, 3), nullable=False, info='上期水表读数')
    voltage = db.Column(db.Numeric(10, 2), info='电压值')
    read_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='抄表类型:自动上报，手动上报')
    read_time = db.Column(db.DateTime, info='抄表时间')
    read_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='抄表人')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='当前状态')
    valve_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='阀门状态')
    voltage_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='电压状态')
    alarm_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='报警状态')
    signal_quality = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='信号质量')
    is_valid = db.Column(db.Integer, nullable=False, info='有效标识')
    is_deduction = db.Column(db.Integer, info='是否已扣费')
    dept_id = db.Column(db.BigInteger, info='机构id')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否已删除')



class WuMeterRecordDetail(db.Model):
    __tablename__ = 'wu_meter_record_detail'
    __table_args__ = (
        db.Index('IX_meter_period', 'water_meter_id', 'period'),
    )

    id = db.Column(db.BigInteger, primary_key=True, info='ID')
    meter_record_id = db.Column(db.BigInteger, nullable=False, info='抄表记录ID')
    water_meter_id = db.Column(db.BigInteger, nullable=False, index=True, info='水表ID')
    device_id = db.Column(db.BigInteger, nullable=False, info='设备id')
    imei = db.Column(db.String(15, 'utf8mb4_0900_ai_ci'), nullable=False, info='IMEI')
    last_read_number = db.Column(db.Numeric(12, 3), info='期末读数')
    period_number = db.Column(db.Numeric(12, 3), nullable=False, info='用水量')
    last_signal_quality = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='期末信号质量')
    period = db.Column(db.Date, index=True, info='日期间')
    hour_period = db.Column(db.Integer, info='小时期间')
    minute_period = db.Column(db.Integer, info='分钟期间')
    dept_id = db.Column(db.BigInteger, info='机构id')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否已删除')



class WuOperationLog(db.Model):
    __tablename__ = 'wu_operation_log'

    id = db.Column(db.BigInteger, primary_key=True, info='操作日志Id')
    plat_device_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), nullable=False, info='平台设备ID')
    water_meter_id = db.Column(db.BigInteger, nullable=False, info='水表ID')
    device_id = db.Column(db.BigInteger, nullable=False, info='设备id')
    imei = db.Column(db.BigInteger, nullable=False, info='IMEI')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='表号')
    device_model_id = db.Column(db.BigInteger, nullable=False, info='设备型号ID')
    operation_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='指令类型')
    operation_content = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='指令内容')
    operation_time = db.Column(db.DateTime, info='下发时间')
    receipt_time = db.Column(db.DateTime, info='回执时间')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='执行状态')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='指令备注')
    dept_id = db.Column(db.BigInteger, info='机构id')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否已删除')



class WuOperationLogDetail(db.Model):
    __tablename__ = 'wu_operation_log_detail'

    id = db.Column(db.BigInteger, primary_key=True, info='明细ID')
    operation_log_id = db.Column(db.BigInteger, nullable=False, info='操作日志id')
    device_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='平台设备Id')
    command_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='平台命令下发id')
    operation_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='指令类型')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='执行状态')
    operation_time = db.Column(db.DateTime, nullable=False, info='下发时间')
    receipt_time = db.Column(db.DateTime, info='回执时间')



class WuPriceDiscount(db.Model):
    __tablename__ = 'wu_price_discount'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    water_use_category_id = db.Column(db.BigInteger, info='用水性质id')
    water_user_type_id = db.Column(db.BigInteger, info='用户类型id')
    discount_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='名称')
    step_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='优惠阶梯类型')
    start_date = db.Column(db.Date, info='起始日期')
    end_date = db.Column(db.Date, info='截止日期')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')

    def to_dict(self):
        """将数据转换为字典"""
        dict = {
            "createDept": self.create_dept ,
            "createTime": self.create_time.strftime("%Y-%m-%d %H:%M:%S") ,
            "createUser": self.create_user ,
            "deptId": self.dept_id ,
            "discountName": self.discount_name ,
            "endDate": self.end_time.strftime("%Y-%m-%d %H:%M:%S"),
            "id": self.id,
            "isDeleted": self.is_deleted,
            "startDate": self.start_date.strftime("%Y-%m-%d %H:%M:%S"),
            "status": self.status,
            "stepType": self.step_type,
            "priceDiscountItems": [item.recover_dict() for item in self.get_discount_item()],
            "tenantId": "",
            "updateTime": self.update_time.strftime("%Y-%m-%d %H:%M:%S"),
            "updateUser": self.update_user,
            "waterUseCategoryId": self.water_use_category_id,
            "waterUserTypeId": self.water_user_type_id
        }
        return dict

    def get_discount_item(self):
        """获取对应的优惠项目"""
        discount_items = WuPriceDiscountItem.query.filter(WuPriceDiscountItem.discount_id==self.id).all()
        return discount_items



class WuPriceDiscountItem(db.Model):
    __tablename__ = 'wu_price_discount_item'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    discount_id = db.Column(db.BigInteger, info='减免优惠id')
    discount_item_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='优惠项目名称')
    step_number = db.Column(db.Integer, info='阶梯数')
    step_start_value = db.Column(db.Integer, info='起始量')
    step_end_value = db.Column(db.Integer, info='截止量')
    fee_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='费用类型')
    discount_amount = db.Column(db.Numeric(12, 2), info='优惠金额')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')

    def recover_dict(self):
        """将数据转换为字典"""
        dict = {
            "createDept": self.create_dept ,
            "createTime": self.create_time,
            "createUser": self.create_user,
            "discountAmount": self.discount_amount,
            "discountId": self.discount_id,
            "discountItemName": self.discount_item_name,
            "feeType": self.fee_type,
            "id": self.id,
            "isDeleted": self.is_deleted,
            "stepEndValue": self.step_end_value,
            "stepNumber": self.step_number,
            "stepStartValue": self.step_start_value,
            "tenantId": "",
            "updateTime": self.update_time,
            "updateUser": self.update_user,
        }
        return dict



class WuPriceRule(db.Model):
    __tablename__ = 'wu_price_rule'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    water_use_category_id = db.Column(db.BigInteger, info='用水性质id')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    rule_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='名称')
    step_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='阶梯类型')
    step_num = db.Column(db.Integer, info='阶梯数量')
    distribute_mode = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='水量分配方式')
    person_num = db.Column(db.Integer, info='定员人口')
    is_late_fee = db.Column(db.Integer, info='是否包含滞纳金')
    late_fee_date = db.Column(db.Integer, info='欠费几天后开始计算滞纳金')
    late_fee_calculation_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='滞纳金计算方式')
    late_fee_amount = db.Column(db.Numeric(10, 5), info='滞纳金金额')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuPriceRuleItem(db.Model):
    __tablename__ = 'wu_price_rule_item'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    rule_id = db.Column(db.BigInteger, info='计价规则ID')
    rule_item_name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='名称')
    step_number = db.Column(db.Integer, info='阶梯数')
    step_end_value = db.Column(db.Numeric(5, 2), info='截止量')
    per_person_value = db.Column(db.Numeric(5, 2), info='人均用量')
    fee_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='费用类型')
    price = db.Column(db.Numeric(12, 2), info='价格')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuProblemType(db.Model):
    __tablename__ = 'wu_problem_type'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    problem_type_name = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='问题分类名称')
    sort = db.Column(db.Integer, info='排序')
    is_deleted = db.Column(db.Integer, nullable=False, info='是否删除')



class WuRecordAlarm(db.Model):
    __tablename__ = 'wu_record_alarm'

    id = db.Column(db.BigInteger, primary_key=True, info='报警Id')
    water_meter_id = db.Column(db.BigInteger, info='水表id')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    read_number = db.Column(db.Numeric(12, 3), nullable=False, info='读数')
    alarm_reason = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='报警原因')
    last_read_number = db.Column(db.Numeric(12, 3), info='上次读数')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='处理状态:待处理、关闭')
    alarm_time = db.Column(db.DateTime, info='上报时间')
    deal_explain = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='处理说明')
    deal_time = db.Column(db.DateTime, info='处理时间')
    deal_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='处理人')
    dept_id = db.Column(db.BigInteger, info='机构ID')



class WuRepair(db.Model):
    __tablename__ = 'wu_repair'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    repair_no = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='维修单号')
    applicant = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='报修人')
    applicant_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='报修人电话')
    water_user_id = db.Column(db.BigInteger, nullable=False, info='用水户ID')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='地址')
    problem_type_id = db.Column(db.BigInteger, nullable=False, info='问题类型ID')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='备注')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构ID')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='状态')
    create_time = db.Column(db.DateTime, nullable=False, info='报修时间')
    user_id = db.Column(db.BigInteger, nullable=False, info='报修用户Id')



class WuRepairAttachment(db.Model):
    __tablename__ = 'wu_repair_attachment'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    repair_id = db.Column(db.BigInteger, nullable=False, info='维修单ID')
    domain = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='域')
    name = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='文件名称')
    link = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='链接')



class WuRepairRecord(db.Model):
    __tablename__ = 'wu_repair_record'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    repair_id = db.Column(db.BigInteger, nullable=False, info='维修单ID')
    water_user_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='用水户号')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='水表号')
    content = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), nullable=False, info='处理记录')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态')
    operate_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='操作人')
    operate_time = db.Column(db.DateTime, nullable=False, info='操作时间')



class WuUserChangeMeter(db.Model):
    __tablename__ = 'wu_user_change_meter'

    id = db.Column(db.BigInteger, primary_key=True, info='换表Id')
    water_use_category_id = db.Column(db.BigInteger, info='用水性质id')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    water_user_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='用水户户号')
    price_id = db.Column(db.BigInteger, nullable=False, info='价格ID')
    water_user_type_id = db.Column(db.BigInteger, info='用水户类型id')
    water_meter_id = db.Column(db.BigInteger, info='水表ID')
    user_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='户名')
    mobile_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='手机号')
    id_card_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='身份证号')
    area_id = db.Column(db.BigInteger, info='所在区域')
    family_population = db.Column(db.Integer, info='常住人口')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='地址')
    account_balance = db.Column(db.Numeric(12, 2), info='账户余额')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='表号')
    device_model = db.Column(db.BigInteger, info='水表型号')
    start_number = db.Column(db.Numeric(12, 3), info='起始读数')
    end_number = db.Column(db.Numeric(12, 3), info='水表止数')
    install_date = db.Column(db.Date, info='安装日期')
    install_location = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='安装位置')
    longitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='经度')
    latitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纬度')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='用水户状态')
    contract_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='合同号')
    new_water_meter_id = db.Column(db.BigInteger, info='新水表ID')
    new_meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='新表表号')
    new_start_number = db.Column(db.Numeric(12, 3), info='新起始读数')
    change_reason_id = db.Column(db.BigInteger, nullable=False, info='换表原因ID')
    change_explain = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='换表说明')
    operate_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='操作人')
    operate_time = db.Column(db.DateTime, info='操作时间')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuUserClose(db.Model):
    __tablename__ = 'wu_user_close'

    id = db.Column(db.BigInteger, primary_key=True, info='过户Id')
    water_user_type_id = db.Column(db.BigInteger, info='用户类型ID')
    water_use_category_id = db.Column(db.BigInteger, info='用水性质id')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    water_user_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='户号')
    price_id = db.Column(db.BigInteger, nullable=False, info='价格ID')
    water_meter_id = db.Column(db.BigInteger, info='水表ID')
    user_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='户名')
    mobile_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='手机号')
    id_card_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='身份证号')
    area_id = db.Column(db.BigInteger, info='所在区域')
    family_population = db.Column(db.Integer, info='常住人口')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='地址')
    account_balance = db.Column(db.Numeric(12, 2), info='账户余额')
    overdue_amount = db.Column(db.Numeric(12, 2), info='滞纳金')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='表号')
    device_model = db.Column(db.BigInteger, info='水表型号')
    start_number = db.Column(db.Numeric(12, 3), info='起始读数')
    end_number = db.Column(db.Numeric(12, 3), info='水表止数')
    install_date = db.Column(db.Date, info='安装日期')
    install_location = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='安装位置')
    longitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='经度')
    latitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纬度')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='用水户状态')
    contract_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='合同号')
    refund_amount = db.Column(db.Numeric(12, 2), info='退款金额')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='备注')
    operate_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='操作人')
    operate_time = db.Column(db.DateTime, info='销户时间')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuUserTransfer(db.Model):
    __tablename__ = 'wu_user_transfer'

    id = db.Column(db.BigInteger, primary_key=True, info='过户Id')
    water_user_type_id = db.Column(db.BigInteger, info='用户类型ID')
    water_use_category_id = db.Column(db.BigInteger, info='用水性质id')
    water_user_id = db.Column(db.BigInteger, info='用水户ID')
    water_user_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='用水户户号')
    price_id = db.Column(db.BigInteger, nullable=False, info='价格ID')
    water_meter_id = db.Column(db.BigInteger, info='水表ID')
    user_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='户名')
    mobile_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='手机号')
    id_card_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='身份证号')
    area_id = db.Column(db.BigInteger, info='所在区域')
    family_population = db.Column(db.Integer, info='常住人口')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='地址')
    account_balance = db.Column(db.Numeric(12, 2), info='账户余额')
    overdue_amount = db.Column(db.Numeric(12, 2), info='滞纳金')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='表号')
    device_model = db.Column(db.BigInteger, info='水表型号')
    start_number = db.Column(db.Numeric(12, 3), info='起始读数')
    end_number = db.Column(db.Numeric(12, 3), info='水表止数')
    install_date = db.Column(db.Date, info='安装日期')
    install_location = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='安装位置')
    longitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='经度')
    latitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纬度')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='用水户状态')
    contract_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='合同号')
    new_water_user_id = db.Column(db.BigInteger, info='新用水户ID')
    new_price_id = db.Column(db.BigInteger, nullable=False, info='新价格ID')
    new_water_user_type_id = db.Column(db.BigInteger, info='新用户类型ID')
    new_user_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='新户名')
    new_mobile_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='新手机号')
    new_id_card_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='新身份证号')
    new_family_population = db.Column(db.Integer, info='新常住人口')
    operate_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='操作人')
    operate_time = db.Column(db.DateTime, info='过户时间')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuValveCloseSetting(db.Model):
    __tablename__ = 'wu_valve_close_setting'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构ID')
    area_id = db.Column(db.BigInteger, nullable=False, info='区域ID')
    close_condition = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='关阀条件')
    threshold_value = db.Column(db.Integer, nullable=False, info='关阀阈值')
    close_time = db.Column(db.Integer, info='关阀时间')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态')



class WuWaterMeter(db.Model):
    __tablename__ = 'wu_water_meter'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    water_user_id = db.Column(db.BigInteger, nullable=False, info='用水户ID')
    device_id = db.Column(db.BigInteger, info='设备ID')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='表号')
    imei = db.Column(db.String(15, 'utf8mb4_0900_ai_ci'), info='IMEI')
    plat_device_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), index=True, info='平台设备ID')
    device_model_id = db.Column(db.BigInteger, info='水表型号')
    start_number = db.Column(db.Numeric(12, 3), info='起始读数')
    install_date = db.Column(db.Date, info='安装日期')
    install_location = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='安装位置')
    longitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='经度')
    latitude = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='纬度')
    current_number = db.Column(db.Numeric(12, 3), info='最新读数')
    last_effective_read_time = db.Column(db.DateTime, info='最后有效抄表时间')
    read_time = db.Column(db.DateTime, info='上报时间')
    read_type = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='抄表类型:自动上报，手动上报')
    voltage_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='电压状态')
    valve_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='阀门状态')
    alarm_status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='报警状态')
    signal_quality = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='信号质量')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    voltage = db.Column(db.Numeric(10, 2), info='电压值')



class WuWaterMeterFeeConfig(db.Model):
    __tablename__ = 'wu_water_meter_fee_config'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构ID')
    device_id = db.Column(db.BigInteger, info='设备ID')
    water_meter_id = db.Column(db.BigInteger, nullable=False, info='水表ID')
    water_user_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='户号')
    meter_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='表号')
    install_date = db.Column(db.DateTime, info='安装日期')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='状态：未开启、开启、停用')
    enable_date = db.Column(db.DateTime, info='开启日期')
    enable_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='开启人')
    disable_date = db.Column(db.DateTime, info='停用日期')
    disable_user = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='停用人')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuWaterUseCategory(db.Model):
    __tablename__ = 'wu_water_use_category'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    water_use_category_name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='用水性质名称')
    sort = db.Column(db.Integer, info='排序')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='备注')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建机构')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='状态')



class WuWaterUser(db.Model):
    __tablename__ = 'wu_water_user'

    id = db.Column(db.BigInteger, primary_key=True, info='用水户Id')
    water_user_type_id = db.Column(db.BigInteger, info='用户类型ID')
    water_use_category_id = db.Column(db.BigInteger, info='用水性质id')
    water_user_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='用水户号')
    price_id = db.Column(db.BigInteger, nullable=False, info='价格ID')
    user_name = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), info='户名')
    mobile_phone = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='手机号')
    id_card_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='身份证号')
    area_id = db.Column(db.BigInteger, info='所在区域')
    family_population = db.Column(db.Integer, info='常住人口')
    address = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='地址')
    last_overdue_date = db.Column(db.DateTime, info='滞纳金最近计费时间')
    overdue_amount = db.Column(db.Numeric(12, 2), info='滞纳金')
    account_balance = db.Column(db.Numeric(12, 2), info='账户余额')
    arrearage_date = db.Column(db.DateTime, info='欠费时间')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='用水户状态：开户、停用、销户')
    yearly_total = db.Column(db.Numeric(12, 3), info='当年累计用水量')
    quarterly_total = db.Column(db.Numeric(12, 3), info='当季累计用水量')
    monthly_total = db.Column(db.Numeric(12, 3), info='当月累计用水量')
    contract_no = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), info='合同号')
    sort = db.Column(db.Integer, info='排序')
    remark = db.Column(db.Text(collation='utf8mb4_0900_ai_ci'), info='备注')
    stop_time = db.Column(db.DateTime, info='停用时间')
    dept_id = db.Column(db.BigInteger, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建部门')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')



class WuWaterUserType(db.Model):
    __tablename__ = 'wu_water_user_type'

    id = db.Column(db.BigInteger, primary_key=True, info='主键')
    water_user_type_name = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='用水户类型名称')
    sort = db.Column(db.Integer, info='排序')
    remark = db.Column(db.String(200, 'utf8mb4_0900_ai_ci'), info='备注')
    dept_id = db.Column(db.BigInteger, nullable=False, info='机构ID')
    create_user = db.Column(db.BigInteger, info='创建人')
    create_dept = db.Column(db.BigInteger, info='创建机构')
    create_time = db.Column(db.DateTime, info='创建时间')
    update_user = db.Column(db.BigInteger, info='更新人')
    update_time = db.Column(db.DateTime, info='更新时间')
    is_deleted = db.Column(db.Integer, info='是否删除')
    status = db.Column(db.String(20, 'utf8mb4_0900_ai_ci'), nullable=False, info='状态')

    def to_dict(self):
        """将对象转换为字典"""
        d = {
            "id": self.id,
            "water_user_type_name": self.water_user_type_name
        }
